package com.delambo.drool.logging;

import com.delambo.drool.interfaces.PropertyMap;
import java.util.*;

/**
 *
 * @author delambo
 */
public class Log_PropertyMap_Impl implements PropertyMap<String, Object> {
    Map<String, Object> prop_set = new HashMap<String, Object>();
    
    public Log_PropertyMap_Impl() {}
    
    public Log_PropertyMap_Impl(String fileName) {
        loadProperties(fileName);
    }
    
    public void loadProperties(final String fileName) {
        final ResourceBundle rb = ResourceBundle.getBundle(fileName);
        prop_set.put("MAIL_SOMEONE", Boolean.parseBoolean(rb.getString("MAIL_SOMEONE")));
        prop_set.put("MAIL_RECIPIENTS", new ArrayList(
                    Arrays.asList(rb.getString("MAIL_RECIPIENTS").split(","))));
        prop_set.put("MAILING_FROM", rb.getString("MAILING_FROM"));
        prop_set.put("MAIL_HOST", rb.getString("MAIL_HOST"));
        prop_set.put("LOG_FILE", rb.getString("LOG_FILE"));
        prop_set.put("LOGGING_LEVEL", Integer.parseInt(rb.getString("LOGGING_LEVEL")));
        prop_set.put("NEWLINE", System.getProperty("line.separator"));
    }
    
    public Object getProperty(String property) {
        return this.prop_set.get(property);
    }
}
